var db = require('../../core/database.js'),
	fs = require('fs'),
	util = require('../../core/module.js');

var config = new util.ConfigModule('security'); // configuration file


function initModule (idModule)
{
	console.log('-*-*-*- '+ idModule + '-*-*-*-');
}

function createModule (moduleName, params, callback)
{
	db.createModule(moduleName, function (idModule)
	{
		config.set(idModule, {'secured': false});
		// TODO : set appropriate sources :
		db.insertAction('enocean_'+params['contact'], 'security/alarm', idModule);
		db.insertAction('enocean_'+params['switch'], 'security/activate_alarm', idModule);
		initModule(idModule);
		callback(idModule);
	});
}

function remove (params) {
	//TODO
}

var requirements = ["contact", "switch"]; // nothing

module.exports.init = initModule;
module.exports.create = createModule;
module.exports.remove = remove;
module.exports.requirements = requirements;
